<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
<title>BirthdayReminder | Start</title>
<link href="css/mystyles.css" rel="stylesheet" type="text/css"/>
</h:head>
<h:body>
<f:view locale="#{languageBean.activeLocale}">
<div align="center">
<h:form id="navform">
<p><h:commandLink id="start" value="#{msg.NavStart}" action="#{startpageBean.doNavigate}" styleClass="navButtonActive"><f:param name="nav" value="start"/></h:commandLink>  
<h:commandLink id="contacts" value="#{msg.NavContacts}" action="#{startpageBean.doNavigate}" styleClass="navButton"><f:param name="nav" value="contacts"/></h:commandLink>  
<h:commandLink id="calendar" value="#{msg.NavCalendar}" action="#{startpageBean.doNavigate}" styleClass="navButton"><f:param name="nav" value="calendar"/></h:commandLink>  
<h:outputText value="#{msg.LoggedInAs} "/><b><h:outputText value="#{usernameUtil.username} "/></b> |
<h:commandLink value="#{msg.NavLogout}" action="#{logoutBean.doLogout}"/></p>
</h:form>
<h1>#{msg.startWelcome}</h1>
<!--<p>
<b>Hint for new Users:</b><br/> 
On this page you can see the next few upcoming birthdays (at least if you've already added some contacts).
<br/>
If you chose to get notified via RSS-Feed, this page is the place where you can subscribe to the feed we generated for you.
<br/>
Furthermore you can view or edit your profile information.
<br/><br/>
To add, edit or delete contacts please go to the "my contacts"-page.
<br/><br/>
If you want to get an overview regarding the birthdays, please head to the "my calendar"-page.
</p> -->
<p>
<h:form id="birthdaysform" >
<div style="width:30%;">
<p:dataTable id="nextbirthdays" var="bday" value="#{startpageBean.comingBirthdays()}" rendered="#{startpageBean.comingBirthdays().size() gt 0 ? 'true' : 'false'}" emptyMessage="---" >
<f:facet name="header">#{msg.startNextBirthdays}</f:facet>
<p:column style="text-align:center;">
<time>
<h:outputText value="#{bday.dob lt 10 ? '0' : ''}#{bday.dob}.#{bday.mob lt 10 ? '0' : ''}#{bday.mob}." escape="false"/>
</time>
</p:column>
<p:column style="text-align:center;">
#{bday.name}
</p:column>
</p:dataTable>
</div>
</h:form>
</p>
<h:panelGroup id="rsspanelgroup">
<h:form id="rssform" rendered="#{startpageBean.wantsRSS}">
<table>
<tr>
<td>#{msg.startGetRSS}</td>
<td><h:outputLink value="#{startpageBean.rsslink}" target="_blank"><img src="pics/rss.png" alt="RSS-Feed"/></h:outputLink></td>
</tr>
</table>
</h:form>
</h:panelGroup>
<b>#{msg.startProfileInfoLabel}</b>
<h:form id="editprofile">
<table>
<!-- <tr>
<td>Username:</td>
<td><h:outputText value="#{startpageBean.puser}" id="profileusername"/></td>
</tr> -->
<tr>
<td>#{msg.startProfileInfoEMail}</td>
<td>
<h:outputText value="#{startpageBean.pemail}" id="profileemail" />
</td>
</tr>
<tr>
<td>#{msg.startProfileInfoNtype}</td>
<td>
<h:outputText value="#{startpageBean.pntype}" id="profilentype" />
</td>
</tr>
<tr>
<td>
<p:commandLink value="#{msg.startProfileInfoEdit}" styleClass="commandLink" update=":formgroup :messages">    
<f:setPropertyActionListener value="#{true}" target="#{startpageBean.editprofilevisible}" />
<f:setPropertyActionListener value="#{false}" target="#{startpageBean.changepwvisible}" />
</p:commandLink>
</td>
<td>
<p:commandLink value="#{msg.startProfileInfoChangePW}" styleClass="commandLink" update=":formgroup :messages">
<f:setPropertyActionListener value="#{true}" target="#{startpageBean.changepwvisible}" />
<f:setPropertyActionListener value="#{false}" target="#{startpageBean.editprofilevisible}" />
</p:commandLink>
</td>
</tr>
</table>
</h:form>

<p:messages id="messages" showDetail="true" globalOnly="true" redisplay="false"/>
<h:panelGroup id="formgroup" >
<h:form id="pwform" rendered="#{startpageBean.changepwvisible}">
<fieldset>
<legend>#{msg.startPasswordLegend}</legend>
<table width="1000" border="0" align="right" >
<tr>
<td width="20%">#{msg.startPasswordOldPWLabel}</td>
<td width="80%"><h:inputSecret id="oldpassword" value="#{startpageBean.poldpw}" required="true" requiredMessage="#{msg.startPasswordOldPWEmpty}"/><h:message id="m0" for="oldpassword" styleClass="error" /></td>
</tr>
<tr>
<td>#{msg.startPasswordPWLabel}</td>
<td><h:inputSecret id="newpassword" value="#{startpageBean.ppw}" required="true" requiredMessage="#{msg.startPasswordPWEmpty}"/><h:message id="m1" for="newpassword" styleClass="error" /></td>
</tr>
<tr>
<td>#{msg.startPasswordConfLabel}</td>
<td><h:inputSecret id="confnewpassword" value="#{startpageBean.pconfpw}" required="true" requiredMessage="#{msg.startPasswordConfEmpty}"/><h:message id="m2" for="confnewpassword" styleClass="error" /></td>
</tr>
<tr>
<td>
<p:commandButton value="#{msg.startPasswordSave}" action="#{startpageBean.doPwChange()}" id="pwsave" update=":formgroup :messages">
</p:commandButton>
</td>
<td>
<p:commandButton value="#{msg.startPasswordCancel}" action="#{startpageBean.cancelPwChange()}" id="pwcancel" update=":messages">
<p:effect event="click" type="fold" for="pwform" />
</p:commandButton>
</td>
</tr>
</table>
</fieldset>
</h:form>
<h:form id="editform" rendered="#{startpageBean.editprofilevisible}">
<fieldset>
<legend>#{msg.startProfileLegend}</legend>
<table width="1000" border="0" align="right">
<tr>
<td width="2%">#{msg.startEmailLabel}</td>
<td width="95%">
<h:inputText id="pemail" value="#{startpageBean.changeemail}" required="true" requiredMessage="#{msg.startEmailError}" validatorMessage="#{msg.startEmailPatternError}">
<f:validateRegex pattern="^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$" />
</h:inputText><h:message id="m3" for="pemail" styleClass="error" />
</td>
</tr>
<tr>
<td>#{msg.startNtypeLabel}</td>
<td>
<h:selectOneMenu id="pntype" required="true" requiredMessage="#{msg.startNtypeError}" validatorMessage="#{msg.startNtypeError}" style="width:150px;">
  	<f:selectItem id="noselection" noSelectionOption="true" itemLabel="- - -" />
    <f:selectItems value="#{startpageBean.ntypelist}" var="type" itemValue="#{type.getId()}" itemLabel="#{type.getType()}"/>
</h:selectOneMenu><h:message id="m4" for="pntype" styleClass="error" />
</td>
</tr>
<tr>
<td><p:commandButton value="#{msg.startPasswordSave}" action="#{startpageBean.doEditProfile()}" update=":editprofile :formgroup :messages :rsspanelgroup"/></td>
<td><p:commandButton value="#{msg.startPasswordCancel}" action="#{startpageBean.cancelEditProfile()}" immediate="true" update=":messages">
<p:effect event="click" type="fold" for="editform" />
</p:commandButton></td>
</tr>
</table>
</fieldset>
</h:form>
</h:panelGroup>
</div>
</f:view>
</h:body>
</html>